﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BurningSphere.Simulator.Controls
{
	/// <summary>
	/// Simple step up on each MIDI note
	/// </summary>
	public class MidiStepControl : MidiControlBase
	{
		int noteMinimum = 0;
		int noteMaximum = 127;


		/// <summary>
		/// Update
		/// </summary>
		/// <param name="matrix"></param>
		public override void Update(Microsoft.DirectX.Matrix matrix)
		{
			base.Update(matrix);
		}

		/// <summary>
		/// Note Minimum
		/// </summary>
		public int NoteMinimum
		{
			get
			{
				return noteMinimum;
			}
			set
			{
				noteMinimum = value;
			}
		}

		/// <summary>
		/// Note Minimum
		/// </summary>
		public int NoteMaximum
		{
			get
			{
				return noteMaximum;
			}
			set
			{
				noteMaximum = value;
			}
		}

		/// <summary>
		/// Note on event
		/// </summary>
		/// <param name="note"></param>
		/// <param name="velocity"></param>
		protected override void OnNoteOn(int note, int velocity)
		{
		//	if (note > NoteMaximum) note = NoteMaximum;
		//	if (note < NoteMinimum) note = NoteMinimum;
			note -= NoteMinimum;
			float range = (float)NoteMaximum - NoteMinimum;
			y = ((float)note - (range / 2.0f)) / range;
		}

		/// <summary>
		/// Note off event
		/// </summary>
		protected override void OnNoteOff()
		{
			y = 0.0f;
		}
	}
}
